﻿using System;
using System.Collections.Generic;
using System.Text;

using ECCIT.Data;

namespace OgilvyOne.UKNow.Utility
{
    public class SqlUtil
    {
        public static int GetMaxRecordID(string tableName, string idColumnName, string langColumnName, int langID)
        {
            string cmdText = string.Format("SELECT (ISNULL(MAX({0}),0) + 1) AS MAXID FROM {1} WHERE {2}={3}", idColumnName, tableName, langColumnName, langID);
            object obj = DBHelper.ExecuteScalar(cmdText);
            if (obj != null && obj != DBNull.Value)
                return (int)obj;

            return 1;
        }
    }
}
